package Year22_Month05.day29_2;

import java.lang.reflect.Constructor;

public class TestEnum {
    public static void main(String[] args) {
//        ColorEnum color = new ColorEnum("RED",1);

        try {
            //获取class对象
            Class<?> enumObj = Class.forName("Year22_Month05.day29_2.ColorEnum");
            //获取构造器
            Constructor<?> enumConstruct = enumObj.getDeclaredConstructor(String.class,int.class,String.class,int.class);
            //修改权限
            enumConstruct.setAccessible(true);
            //创建对象实例
            ColorEnum color = (ColorEnum) enumConstruct.newInstance("YELLOW",4);
            //打印一下
            System.out.println(color);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
